//
//  HomeViewController.m
//  Manage
//
//  Created by 杨康 on 2017/10/30.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "HomeViewController.h"
#import "EvManageViewController.h"
#import "MissingManageViewController.h"
#import "UserManageViewController.h"
#import "StoreManageViewController.h"
#import "BrandViewController.h"
#import "RepairerManageViewController.h"
#import "WithdrawalsViewController.h"
@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.barTintColor = [UIColor colorQ];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationItem.title=@"管理";
    
    
    
    CGFloat width =SCREEN_WIDTH/2;
    CGFloat height = (SCREEN_HEIGHT-TOP_HEIGHT-BOTTOM_HEIGHT)/4;
    
//    ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
    
    
    
    //分割线
    UIView *verticalLine=[[UIView alloc]init];
    verticalLine.backgroundColor=[UIColor colorF];
    [self.view addSubview:verticalLine];
    [verticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(70);
        make.size.mas_equalTo(CGSizeMake(0.5, SCREEN_HEIGHT-70-55));
    }];
    
    for (int i=1; i<4; i++) {
        UIView *horizontalLine=[[UIView alloc]init];
        horizontalLine.backgroundColor=[UIColor colorF];
        [self.view addSubview:horizontalLine];
        [horizontalLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(6);
            make.top.mas_equalTo(TOP_HEIGHT+height*i);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-12, 0.5));
        }];
    }
    
    
//    NSArray *partArray=[NSArray arrayWithObjects:@"电动车管理",@"车辆报失管理",@"门店管理",@"维修厂商",@"电动车品牌",@"用户管理",@"提现管理", nil];
    NSArray *partArray=[NSArray arrayWithObjects:@"电动车管理",@"车辆报失管理",@"用户管理", nil];
    
    
    for (int i=0; i<partArray.count; i++) {
        int a=i/2;
        int b=i%2;
        UIButton * functionButton=[SingLeton endButton:nil andTitle:partArray[i] RequestSuccess:^(UIButton *btn) {
            NSString *title=btn.titleLabel.text;
            if ([title isEqualToString:@"电动车管理"]) {
                EvManageViewController *vc=[[EvManageViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
            }else if ([title isEqualToString:@"车辆报失管理"])
            {
              
                MissingManageViewController *vc=[[MissingManageViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
            }
            else if ([title isEqualToString:@"门店管理"])
            {
                
                StoreManageViewController *vc=[[StoreManageViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
            }
            else if ([title isEqualToString:@"维修厂商"])
            {
                
                RepairerManageViewController *vc=[[RepairerManageViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
                
                
                
            }
            else if ([title isEqualToString:@"电动车品牌"])
            {
                
                BrandViewController *vc=[[BrandViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
            }
            else if ([title isEqualToString:@"用户管理"])
            {
                
                UserManageViewController *vc=[[UserManageViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
            }
            else if ([title isEqualToString:@"提现管理"])
            {
                WithdrawalsViewController *vc=[[WithdrawalsViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
                
                
            }
            
            
        }];
        [self.view addSubview:functionButton];
        [functionButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(TOP_HEIGHT+height*a);
            make.left.mas_equalTo(width*b);
            make.size.mas_equalTo(CGSizeMake(width, height));
        }];
        
        [functionButton setTitleColor:[UIColor color3] forState:UIControlStateNormal];
        functionButton.titleLabel.font=[UIFont systemFontOfSize:16];
        [functionButton setImage:[UIImage imageNamed:partArray[i]] forState:UIControlStateNormal];
    
        [functionButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleTop imageTitleSpace:5.0];

    }
    
}





@end
